
package org.jetnuke.dao.generic;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import net.jforum.JForumExecutionContext;
import net.jforum.util.preferences.SystemGlobals;

import org.jetnuke.entities.Censore;

public class GenericCensoreDAO implements org.jetnuke.dao.CensoreDAO {

	/* (non-Javadoc)
	 * @see org.jetnuke.model.CensoreModel#selectAll()
	 */
	public List selectAll() throws Exception {
		PreparedStatement p =  JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("CensoreModel.selectAll"));
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();
		return list;
	}
	/**
	 * @param rs
	 * @return
	 */
	protected List processSelectAll(ResultSet rs)throws Exception {
		List list = new ArrayList();
		while (rs.next()) {
			Censore u = new Censore();
			fillCensoreFromResultSet(u,rs);			
			list.add(u);
		}
		return list;

	}
	/**
	 * @param u
	 * @param rs
	 */
	protected void fillCensoreFromResultSet(Censore u, ResultSet rs) throws Exception{
		u.setID(rs.getInt("ID"));
		u.setWORD(rs.getString("WORD"));
		
	}


}
